import { StoreSvr } from './../../services/store';
import { PlayAudioService } from './../../components/play-audio';
import { ConfigSvr } from './../../services/config';
import { Component, OnInit } from '@angular/core';

@Component({
    selector: 'forbidden',
    styleUrls: ['./index.scss'],
    template: `
        <div class="forbidden-container">
            <div class="status">当前出品台已{{open ? "开启" : "禁用"}}</div>
            <p class="desc">禁用该出品台，将导致当前出品台停止接收订单，并从收银台中删除。要使用出品台，请再次开启。</p>
            <button (click)="toggle()" class="btn" [ngClass]="{'forbidden_btn':open, 'open_btn':!open}">{{open ? "禁用" : "开启"}}该出品台</button>
        </div>
    `
})
export class Forbidden implements OnInit {
    constructor(private configSvr: ConfigSvr, private storeSvr: StoreSvr) { }

    open;

    ngOnInit() {
        this.open = this.storeSvr.currentDevice.isShared;
    }
    
    toggle() {
        this.open = !this.open;

        if (this.open) {
            this.storeSvr.openDevice();
        } else {
            this.storeSvr.forbiddenDevice();
        }
    }
}